﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FCTC_Web.Models;
using DAL;

namespace FCTC_Web.Controllers.Business.BusinessModel
{
    // "问答", "市场", "促销", "拍卖", "热点", "知识", "车展","活动", "政策","其它"
    public class AriticleBusiness
    {
        public static AriticleBusiness _ins = new AriticleBusiness();
        public static AriticleBusiness Ins
        {
            get { return _ins; }
        }

        public List<Article> MarketNews
        {
            get { return CH.GetAllData<Article>(i => i.ArticleType == "市场").OrderByDescending(i => i.Sequense).ToList(); }
        }
        public List<Article> QA
        {
            get { return CH.GetAllData<Article>(i => i.ArticleType == "问答").OrderByDescending(i => i.Sequense).ToList(); }
        }
        public List<Article> Auctions
        {
            get { return CH.GetAllData<Article>(i => i.ArticleType == "拍卖").OrderByDescending(i => i.Sequense).ToList(); }
        }
        public List<Article> Knowledge
        {
            get { return CH.GetAllData<Article>(i => i.ArticleType == "知识").OrderByDescending(i => i.Sequense).ToList(); }
        }
        public List<Article> VehicleShows
        {
            get { return CH.GetAllData<Article>(i => i.ArticleType == "车展").OrderByDescending(i => i.Sequense).ToList(); }
        }

        public List<Article> Activities
        {
            get { return CH.GetAllData<Article>(i => i.ArticleType == "活动").OrderByDescending(i => i.Sequense).ToList(); }
        }

        public List<Article> NewVechiles
        {
            get { return CH.GetAllData<Article>(i => i.ArticleType == "新车").OrderByDescending(i => i.Sequense).ToList(); }
        }
        public List<Article> Policies
        {
            get { return CH.GetAllData<Article>(i => i.ArticleType == "政策").OrderByDescending(i => i.Sequense).ToList(); }
        }
        public List<Article> Discount4S
        {
            get { return CH.GetAllData<Article>(i => i.ArticleType == "促销").OrderByDescending(i => i.Sequense).ToList(); }
        }

        public List<Article> Brands
        {
            get { return CH.GetAllData<Article>(i => i.ArticleType == "品牌").OrderByDescending(i => i.Sequense).ToList(); }
        }

        public List<Article> Documents
        {
            get { return CH.GetAllData<Article>(i => i.ArticleType == "文档").OrderByDescending(i => i.Sequense).ToList(); }
        }
    }

    public class AriticledetailBusiness
    {
        public Article Article { get; set; }
        public AriticledetailBusiness(int? i)
        {
            Article  = CH.GetDataById<Article>(i);
            if (Article == null)
                throw new Exception("该文章已经删除在");
        }

        public List<Article> Relatives
        {
            get { return CH.GetAllData<Article>(i => i.ArticleType == Article.ArticleType && i.ID!= Article.ID).OrderByDescending(i => i.ReportingTime).ToList(); }
        }
    }

}